﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Xml;
using System.Reflection;

namespace WebCommit.Crawler
{
	public class WorkerConfigurationSectionHandler : IConfigurationSectionHandler
	{
		
		public object Create(object parent, object configContext, System.Xml.XmlNode section)
		{
			List<WorkerConfig> list = new List<WorkerConfig>();
			foreach (XmlNode node in section.ChildNodes)
			{
				WorkerConfig cfg = new WorkerConfig();
				string typeStr = node.Attributes["type"].Value;
				string countStr = node.Attributes["count"].Value;
				cfg.WorkerType = Type.GetType(typeStr);
				cfg.Count = int.Parse(countStr);
				list.Add(cfg);
			}
			return list;
		}

	}

	public class WorkerConfig
	{
		public Type WorkerType
		{
			get;
			set;
		}
		public int Count
		{
			get;
			set;
		}
	}
}
